#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh

debug() {
    echo "[$(date '+%H:%M:%S')] [DEBUG] $1" >&2
}

check() {
    debug "check ${srcmods}"
    return 0
}

depends() {
    debug "depends ${srcmods}"
    return 0
}

install() {
    debug "install ${srcmods}kernel/drivers/arkins"
    rm -rf /usr/sbin/modtest
    touch /usr/sbin/modtest
    cat << EOF > /usr/sbin/modtest
#!/bin/bash
echo "Hello, World"
insmod ${srcmods}kernel/drivers/arkins/modtest.ko
EOF
    chmod 550 /usr/sbin/modtest
    inst /usr/sbin/modtest

    rm -rf ${srcmods}kernel/drivers/arkins
    mkdir -p ${srcmods}kernel/drivers/arkins
    cp /root/projects/studylinux/kernel/ex1/modtest.ko ${srcmods}kernel/drivers/arkins/modtest.ko
    return 0
}

installkernel() {
    debug "installkernel ${srcmods}"
    hostonly='' instmods modtest
    return 0
}
